package com.d0326;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class TestHashSet2 {
    public static void main(String[] args) {
        Set<Student> set=new HashSet<>() ;
        Student stu1=new Student("Jack",21,98);
        Student stu2=new Student("Bright",22,100);
        Student stu3=new Student("Jack",21,98);
        set.add(stu1);
        set.add(stu2);
        set.add(stu3);
        System.out.println("个数为:"+set.size());//重写equals方法后stu3==stu1，所以只存一个
        for (Student s:set
             ) {
            System.out.println(s);
        }
    }
}
